package com.lms.logistics_management_system.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lms.logistics_management_system.controller.dto.ReservationItemDto;
import com.lms.logistics_management_system.entity.Item;
import com.lms.logistics_management_system.entity.QueueCondition;
import com.lms.logistics_management_system.entity.Reservation;
import com.lms.logistics_management_system.entity.ReservationItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface ReservationItemMapper extends BaseMapper<ReservationItem> {


    @Update("UPDATE reservation_item SET reservation_item_result_comeout=1 WHERE reservation_id=#{reservationId} AND item_id=#{itemId}")
    boolean changeReservationItemStatus(Integer reservationId, Integer itemId);

    @Select("SELECT * FROM reservation r\n"+
            "LEFT JOIN reservation_item ri ON r.reservation_id=ri.reservation_id \n"+
            "LEFT JOIN item i ON i.item_id=ri.item_id \n"+
            "WHERE user_openid =#{openid}\n"+
            "ORDER BY r.reservation_id,ri.item_id;")
    List<ReservationItemDto> getAllResItemInfo(String openid);

    //SELECT * FROM reservation r
    //            LEFT JOIN reservation_item ri ON r.reservation_id=ri.reservation_id
    //            LEFT JOIN item i ON i.item_id=ri.item_id
    //            ORDER BY r.reservation_id,ri.item_id;
}
